Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • SOUPSOUP: just get a vpn
      August 13, 2018, 06:44:28 PM
    • jme: _^_ will answer all of your javascript questions
      August 12, 2018, 07:11:00 PM
    • doomsale: and where is boxman?
      August 10, 2018, 03:16:59 AM
    • doomsale: Where can i play the Moparscape MMORPG with the Metallica instrumentals?
      August 10, 2018, 03:16:47 AM
    • doomsale: no longer clicking on doors and dummies at east bank
      August 10, 2018, 03:16:07 AM
    • doomsale: were all grown up now huh?
      August 10, 2018, 03:15:58 AM
    • _^_: hey everyone look at my graphs [link]
      August 06, 2018, 01:52:16 PM
    • braedyn: Someone pl0x help me out with PI Lottery!!
      August 03, 2018, 02:12:25 AM
    • Travas: p3n1s
      July 26, 2018, 09:46:33 PM
    • Krackkid: You up :eggplant:
      July 23, 2018, 06:18:17 PM
    • DeathsChaos9: no
      July 23, 2018, 03:53:31 PM
    • Emulous: Come check out Emulous: [link]
      July 22, 2018, 03:37:19 PM
    • Emulous:[link]
      July 22, 2018, 03:37:00 PM
    • Travas: ur mom
      July 21, 2018, 06:04:50 PM
    • YNRDAB: Watcha big ballers up too?
      July 20, 2018, 11:01:06 AM
    • dark250: i need help for coding client
      July 19, 2018, 08:27:37 AM
    • Travas: yes
      July 14, 2018, 02:19:44 PM
    • drubrkletern: lmao racist and sexist much?
      July 14, 2018, 01:11:52 PM
    • Cole1497: yeah i got you lil boat give me a second
      July 13, 2018, 03:19:35 AM
    • B0ATY.: yo can anyone unban my ip, i got banned for saying i hope someone gets aids :p
      July 12, 2018, 09:16:00 PM

    Author Topic: Random code generator  (Read 1629 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineSpecial Air Service

    • Member
    • ***
    • Posts: 103
    • Thanks: +0/-0
      • View Profile
    Random code generator
    « on: June 30, 2014, 01:23:26 PM »
    So guys i just quickly made this, can y'all tell me if its alright?

    Code: [Select]
    import java.util.Random;

    /**
     * This class is used to auto generate random codes
     * Made this just as an experiment
     * @author Zack
     *
     */

    public class RandomCodeGenerator {

    /**
    * This is all the Keys that can be made in the code generator
    */

    private static String[] keys = {
    "1", "2", "3", "4", "5", "5", "6", "7", "8", "9",
    "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
    "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
    "U", "V", "W", "X", "Y", "Z"
    };

    /**
    * This is the String for the code
    */

    static StringBuilder sb = new StringBuilder();

    /**
    * This variable determains how much codes you generate
    */

    public final static int REPEAT = 10000;

    /**
    * This variable counts how much characters will be in the code itself
    */

    public final static int CHARACTERS = 25;

    /**
    * This variable places a dash after a certain amount of characrtes, so for instance
    * if it is set to 5 it will put a dash after every 5 characters
    */

    public final static int DASH = 5;

    /**
    * This will generate a randomized code and return the value
    * @return StringBuilders value, all the Strings that have been appended
    */

    public static String generateCode(){
    Random r = new Random();
    int counter = 0;
    int dashCounter = 0;
    sb.delete(0, CHARACTERS);
    for(int i = 1; i <= CHARACTERS; i++){
    sb.append(keys[r.nextInt(keys.length - 1)]);
    counter++;
    if(counter == DASH){
    dashCounter++;
    if(dashCounter == CHARACTERS / DASH){ } else {
    sb.append("-");
    counter = 0;
    }
    }
    }
    return sb.toString();
    }

    /**
    * This is the main method that will repeat the code generator
    * @param args
    */

    public static void main(String[] args) {
    for(int i = 0; i < REPEAT; i++){
    System.out.println(generateCode());
    sb.delete(0, CHARACTERS);
    }
    }
    }

    here is an example how the codes look

    Code: [Select]
    BQ935-14CKK-64Z8N-PLESN-HHBDZ
    5H45P-MEC9H-NM2TA-FF22S-XQX6L
    P7BXD-FUM21-JRY5R-GVNEM-KIU4B
    W5WTI-AKYEM-NO7EN-UUWG4-5NO7R
    XUB43-3BZTY-K3FBK-Z9HDS-PHUDF
    RDTUA-X9USV-CUPWN-8Q92J-IOOVC
    YJS3E-D5GJS-3COPL-SLU33-TB8SU
    UGHI1-7KW1O-XPLTN-S4DEF-5USVE
    TP4GI-C6OE5-CI8CM-4BAC2-M88BU
    RK7RZ-BGK1V-WZSK7-R8Q52-NFM3A
    8CKWM-8HTCV-YWSJM-LCKRT-KX6ZB
    16BVU-7NQMG-55FCQ-K33DZ-62Z38
    WL1AT-PD595-IKVIX-C4OIE-4BKRG
    66ZCO-FNY9B-OYY1R-VNI87-JENI3
    OSJ6D-A5K2W-ZBEW9-SXSOR-IPJWW
    GJ53Q-UJ6TL-54VY9-3SP4J-1UR9F
    26S23-CYL6A-7NZ75-7JUOE-4NUBC
    JASCT-I5CYA-15AKV-72Y7X-CK3BQ
    VGS5X-YQFBY-D16NL-P35AI-ECMWU
    CZ1H5-859P7-WPD1Z-JFWOE-YF3ZQ
    NUOML-2RFJY-UCYOX-AOTPW-5GTZ8
    AU43B-DJLHR-96UZ5-ZQANL-XYO9N
    YFING-5RRP3-N3UK8-2L25U-N8N2F
    W8BGS-7DUI3-3K5GZ-1WSCB-D4CPT
    5SB5E-D34HA-Q571X-LEZUE-9J53C
    TDDE3-39XVU-Y9U22-GMQFB-FBMCZ
    M6WMI-4IEPJ-BUPD3-GIM7D-2ZX8P
    GNN2Y-RN28W-GVG3W-4FHN5-IUVIM
    A1QOU-Y7YW5-R8AJL-3SJ9O-X5F4W
    65K8F-CC7I9-LUN63-ENRXW-BX9RN
    SVYAV-S2T3E-ETYES-BVHBS-IQ9X9
    Q3DO3-9M944-6NG3N-3I7QM-LWJQ3
    GXOLX-5QIQF-Y75QB-HIAOM-KQO55
    NJPNG-85TNK-XR5P9-7FN2U-5OB7O
    QP6NN-5CWAR-R19QV-RX439-PJEY9
    YYKL9-W8QBW-C5V53-SJ5UZ-P1PIW
    83JXA-HWU2I-S9W9C-X86UF-DIFCU
    6NFM2-ZHBSN-ZQ9K3-G5D6K-8NVU9
    YZLBD-V8ESU-NMQCL-IX5D5-KIV55
    4USEE-DXMPV-6AICK-MP5I5-NK1O8
    UTCWJ-66KV2-87KL9-DDY5R-HAP49
    G1Q9M-SWGEF-IB5ID-C37ZI-SWXT5
    D46XW-7DL5W-JG8FN-ZQXH3-9BGPP
    DAJMM-GN7R9-TD9J9-FHVRT-Y6P15
    12WFS-NE8RT-MZ44E-4CY8W-77Z4A
    Q1MAU-M29KP-9UKNW-PE5FK-XX3DZ
    YJ2YI-9M8F9-7GKRK-RMN9P-ZX3WU
    W55BV-M3FA5-I44U8-Z5UXP-TCLBF
    ZR1ZK-5GTN1-W1OI5-UI55C-W1X5U
    Z8ZA9-CPZPE-3LNL9-CBFF1-7EUOM
    ETMZI-YRZHS-Z3T7T-89U7E-VGEJ3
    4HI87-LPNRV-KGOK8-W4KB4-VV7LD
    G25DK-JDOBJ-55WK6-Q3E9P-DUASU
    LSTNG-9Z239-TUERG-698WA-WVNUP
    2SGKB-7IB7C-6PXI2-DSJSD-5QMDR
    85XB2-32D9G-5B5MC-PGX3F-J456N
    RGN4Q-ZPSGV-6KY8M-PUK6O-G4JFT
    CBAOT-2EKQ3-9WUOW-5L5XK-GCSR2
    OYFQY-NJXOD-NJV4C-DU36O-1MDIG
    RKS48-UQ19F-ODU4Q-725HO-9LOZN
    GQDY5-PIY4V-88K5F-HBBYG-ILHKL
    VB4OF-TX9T6-BBB4C-ZQBYQ-GDIQ1
    G53PN-W5WM7-7C6DI-8NFU8-1884H
    E68KB-1F4SE-DZL46-8K76N-WT9Y6
    226QR-P7HPJ-QXJU1-P859Z-V35KX
    ID7PP-LZCZQ-R856C-FY5R7-5RSZW
    VL2Q5-PECT5-FVZ89-KFTFL-NW77N
    B9GXD-YMDSM-2R3YI-VKPIJ-5H5FN
    I6UOB-P5Z8T-FXM1H-POWAE-5LC5X
    ENJBP-5BW9O-VJQO5-9DKF3-HYF6T
    B6SZH-RLS7H-E7JI5-7PQEE-NFK7O
    GXKXB-1RY9D-8WVWB-6FKUF-12AD3
    IBGK8-BW3AB-MUE44-DOMNA-K6M53
    S8LDV-I2G6W-1AW7J-65YCE-Z56K3
    O56GQ-PZX11-8SZAQ-TP4US-MLWTT
    9SZOE-72E4B-OBTV8-F7B6Q-BXB7F
    QAVO1-T5J5O-RCA5J-UGUD5-P2G3V
    8YXBJ-CH712-P7PO9-3X5KR-HDVND
    594NT-XBFI4-GV1GZ-BPUQ2-QOW1S
    SMLYB-TJ3IK-B4VU3-T3D2F-BFN5S
    ZC78I-DX45K-XC17F-FFDUU-ITOPI
    JZ79B-YX3DX-2B52F-XB6H6-FS3JO
    3B8QH-XIV73-5JP86-L6JPK-59Z75
    IYT3W-K4UYE-DSPRG-ZEPM5-WK5NG
    IXEI5-V5AXT-JPDLD-RLA11-GE5IY
    J8NBM-AVYD6-RF9T1-TAEZP-C2BEM
    95RW5-POJZ3-5GRQL-NTSE4-FTCGB
    B4ZWC-Q6SGE-J1Z7A-265K2-HS363
    LCJB1-XD62F-HF9G9-WC5SW-G1OGK
    U3Y7X-7WL4M-P968Y-GRH73-5KCRL
    UN819-TYGXI-N1RI1-ON1U3-I9C87
    GPSRS-B6PCO-GM47Y-7M5FP-KVWYF
    HQGCN-UUUAT-DWJZ2-R3AXM-EXE98
    L7SAR-C6SSV-TIV7J-ZJPZS-LW2VI
    N6ALV-3NMGX-76KGD-JAUNU-PCQPP
    UY3AY-XQW2Q-ZUD4U-D1L8Q-L7RA8
    2MH29-6UBW7-S42UX-FK7QO-AMURT
    9GMCH-82UUU-Q4UEM-UWQLP-ZZ5LV
    PAADV-86NSZ-Q269K-LZV9R-WF7Z8
    W5W6D-WXH75-WEVVL-MFGNZ-UJ7Z5
    « Last Edit: June 30, 2014, 04:25:27 PM by Special Air Service »
    Runescape Gambling

    Offlineimthenull

    • Member
    • ****
    • Posts: 2,511
    • Thanks: +1/-0
      • View Profile
    Re: Random code generator
    « Reply #1 on: June 30, 2014, 01:32:58 PM »
    Why not use uuid? http://docs.oracle.com/javase/8/docs/api/java/util/UUID.html

    edit:
    If this just for educational purposes, then good job. Although the implementation could use a little abstraction.
    Runescape Gambling

    OfflineSpecial Air Service

    • Member
    • ***
    • Posts: 103
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #2 on: June 30, 2014, 01:37:24 PM »
    yea it was for pure educational purposes :), and show me with the abstract?
    Runescape Gambling

    OfflineHcoJustin

    • Member
    • ****
    • Posts: 2,400
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #3 on: June 30, 2014, 01:55:05 PM »
    The design could use a little bit of help, and you'll probably want to follow some sort of algorithm if you are going to generate keys for software use. Randomization will allow anyone to generate a key and you have no way to check the validity.

    OfflineSpecial Air Service

    • Member
    • ***
    • Posts: 103
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #4 on: June 30, 2014, 02:01:24 PM »
    The design could use a little bit of help, and you'll probably want to follow some sort of algorithm if you are going to generate keys for software use. Randomization will allow anyone to generate a key and you have no way to check the validity.

    this isnt for any type of software, this is made to just randomize String's lol :P

    OfflineDavidi2

    • Member
    • ****
    • *
    • Posts: 23,272
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #5 on: June 30, 2014, 02:46:14 PM »
    You generated javadoc comments but didn't fill out the tags :)

    OfflineSpecial Air Service

    • Member
    • ***
    • Posts: 103
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #6 on: June 30, 2014, 03:27:32 PM »
    You generated javadoc comments but didn't fill out the tags :)

    how is it now?

    OfflineDavidi2

    • Member
    • ****
    • *
    • Posts: 23,272
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #7 on: June 30, 2014, 03:34:47 PM »
    Now you messed up the spacing, should be an empty line before each javadoc comment. Also it needs to be more descriptive, can't just say 'value'

    OfflineSpecial Air Service

    • Member
    • ***
    • Posts: 103
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #8 on: June 30, 2014, 03:41:42 PM »
    Now you messed up the spacing, should be an empty line before each javadoc comment. Also it needs to be more descriptive, can't just say 'value'

    how is it now

    OfflineDavidi2

    • Member
    • ****
    • *
    • Posts: 23,272
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #9 on: June 30, 2014, 04:10:07 PM »
    Better, but some of your definitions are wrong.

    For the stringbuilder, the return isn't "the strings that have been appended", it's a single "code" or "key" or whatever you call them. You might also want to give an example of the format returned in the method description.

    Also, variables shouldn't be all capital letters unless they are constants (things that never change value, usually declared static final). Use camelCaseWhichLooksLikeThis for almost everything else.

    Offlinewildskiller

    • Member
    • ****
    • Posts: 1,435
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #10 on: June 30, 2014, 04:34:11 PM »
    The design could use a little bit of help, and you'll probably want to follow some sort of algorithm if you are going to generate keys for software use. Randomization will allow anyone to generate a key and you have no way to check the validity.
    If you use the one-time pad, you can generate the codes with a random shift for each letter. The key would be stored into an array so only the person who generated the codes knows it.

    OfflineSpecial Air Service

    • Member
    • ***
    • Posts: 103
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #11 on: June 30, 2014, 04:52:15 PM »
    The design could use a little bit of help, and you'll probably want to follow some sort of algorithm if you are going to generate keys for software use. Randomization will allow anyone to generate a key and you have no way to check the validity.
    If you use the one-time pad, you can generate the codes with a random shift for each letter. The key would be stored into an array so only the person who generated the codes knows it.

    This is not part of a game or nothing, so it dosnt really matter who sees the code or knows it

    OfflineSnow_

    • Member
    • ***
    • Posts: 161
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #12 on: June 30, 2014, 05:13:52 PM »
    Probably just something you overlooked, but you're clearing your stringbuilder twice for each code you generate! You do this before you start looping  in the generateCode function and after you printed out the code in the main method!

    OfflinePwnd

    • pround player of moparscape.org
    • Member
    • ****
    • *
    • *
    • Posts: 8,553
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #13 on: June 30, 2014, 05:18:42 PM »
    Code: Ruby
    1. putsrand(36**28).to_s(36).gsub(/(.{4})(?=.)/, '\1-\2').upcase
    [ +lawl ] web dev more like pleb dev

    Offlinewildskiller

    • Member
    • ****
    • Posts: 1,435
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #14 on: June 30, 2014, 05:21:36 PM »
    The design could use a little bit of help, and you'll probably want to follow some sort of algorithm if you are going to generate keys for software use. Randomization will allow anyone to generate a key and you have no way to check the validity.
    If you use the one-time pad, you can generate the codes with a random shift for each letter. The key would be stored into an array so only the person who generated the codes knows it.

    This is not part of a game or nothing, so it dosnt really matter who sees the code or knows it
    I was giving you some useful information. It's always good to absorb details like this.

    This is an example of using the One-Time pad. In this code, I generate a random line of code, encrypt it and then decrypt it.
    Code: Java
    1. importjava.util.ArrayList;
    2. importjava.util.List;
    3.  
    4. publicclass OneTimePad {
    5.        
    6.         /**
    7.          * length of the alphabetical shift
    8.          */
    9.         finalstaticbyte length =25;
    10.        
    11.         /**
    12.          * stored value of random alphabetical shifts
    13.          */
    14.         staticchar[] key =newchar[length];
    15.        
    16.         /**
    17.          * characters of the alphabet
    18.          */
    19.         staticchar[] alphabet ={
    20.                 'A', 'B', 'C', 'D', 'E',
    21.                 'F', 'G', 'H', 'I', 'J',
    22.                 'K', 'L', 'M', 'N', 'O',
    23.                 'P', 'Q', 'R', 'S', 'T',
    24.                 'U', 'V', 'W', 'X', 'Y',
    25.                 'Z'
    26.         };
    27.        
    28.         publicstaticvoid main(String[] args){
    29.                 //list to hold the generated codes
    30.                 List<String> codes =new ArrayList<String>();
    31.                 for(short i =0; i <1000; i++){
    32.                         //Build of the original string
    33.                         StringBuilder original =new StringBuilder(length);
    34.                         //Build of the encrypted string
    35.                         StringBuilder encrypted =new StringBuilder(length);
    36.                         //Build of the decrypted string
    37.                         StringBuilder decrypted =new StringBuilder(length);
    38.                         byte dashIncr =0;
    39.                         for(byte b =0; b < length; b++){
    40.                                 //random index (0-25) for the original character
    41.                                 byte c =(byte)(Math.random()*26);
    42.                                 //random index (0-25) for the shift
    43.                                 byte shift =(byte)(Math.random()*26);
    44.                                 //value of character index after applying shift
    45.                                 byte afterShift =(byte)((c + shift)%26);
    46.                                 //value of character index after removing the shift
    47.                                 byte decrypt =(byte)((afterShift - shift)%26);
    48.                                 key[b]= alphabet[shift];
    49.                                 if(dashIncr >=5){
    50.                                         dashIncr =0;
    51.                                         original.append('-');
    52.                                         encrypted.append('-');
    53.                                         decrypted.append('-');
    54.                                 }
    55.                                 original.append(alphabet[c]);
    56.                                 encrypted.append(alphabet[afterShift]);
    57.                                 decrypted.append(alphabet[decrypt <0? decrypt +26: decrypt]);
    58.                                 dashIncr++;
    59.                         }
    60.                         codes.add(original.toString()+" | "+encrypted.toString()+" | "+decrypted.toString());
    61.                 }
    62.                 System.out.print("Key: ");
    63.                 for(char c : key){System.out.print(c);}
    64.                 System.out.println();
    65.                 System.out.println();
    66.                 for(String s : codes){System.out.println(s);}
    67.         }
    68.  
    69. }
    70.  

    Output: (ORIGINAL | ENCRYPTED | DECRYPTED)
    Code: [Select]
    Key: AJPGZXEEHMSEJZIPYIRMYEDHY

    INNUZ-KUEFL-HEBSZ-DUJTT-RIDLP | RZNGY-LJNDB-ZWEQK-DYOJL-MPCTF | INNUZ-KUEFL-HEBSZ-DUJTT-RIDLP
    NLGBR-PCUEC-FYBWW-ZCKVW-CDZFJ | ESZWY-XLDPW-VHZES-UQHCR-RCMXR | NLGBR-PCUEC-FYBWW-ZCKVW-CDZFJ
    LDUYS-FVODT-OUBAK-HPZFC-GIVZY | BUNPX-YSJUH-WBDNC-TVHZI-TTNWZ | LDUYS-FVODT-OUBAK-HPZFC-GIVZY
    OBQXT-GECRL-NCWZW-UMMPH-AVKOD | IOOEV-LQHRP-BRLYT-NHSQG-NVTMB | OBQXT-GECRL-NCWZW-UMMPH-AVKOD
    DRFTS-SFHOW-DGETY-VZGVD-CJGMH | CNWOC-PEPVS-MKAAQ-DLRGR-HOBJY | DRFTS-SFHOW-DGETY-VZGVD-CJGMH
    ESDDK-HLLEJ-OOGXX-WKNHS-QOJBV | WKDSC-AFNRO-BRKCT-CSLTE-DCLRY | ESDDK-HLLEJ-OOGXX-WKNHS-QOJBV
    MNVVL-JVQWI-OCTSI-QTWXO-FTRBG | DLERA-ELIGX-TQDPD-INJTZ-ORBCB | MNVVL-JVQWI-OCTSI-QTWXO-FTRBG
    FRILA-TVIYO-YWCGP-KRNIJ-EDIUT | REXVF-VGIGP-IDCOK-DJAJS-SRNGR | FRILA-TVIYO-YWCGP-KRNIJ-EDIUT
    YVLCA-JCFCS-GOFEM-EIZZA-XQWXN | KBPJC-SZNJE-PIJWN-JFKWY-CCAWR | YVLCA-JCFCS-GOFEM-EIZZA-XQWXN
    QCDKX-ZUJYF-KAYFW-WMMKW-MRXMB | QFCWP-TKBKU-XBMQB-APPZY-DFQXJ | QCDKX-ZUJYF-KAYFW-WMMKW-MRXMB
    SNEPU-RZLGA-UBYLJ-WDTXB-CJWNK | WHMFU-VUDPZ-RPXJW-YDLLW-FRQUL | SNEPU-RZLGA-UBYLJ-WDTXB-CJWNK
    ABNEP-YQQHN-CIDER-IBXTI-ILDVH | XEKRX-KLOFR-IYVQE-IRAAI-OPXHL | ABNEP-YQQHN-CIDER-IBXTI-ILDVH
    UULBV-ICFCO-RNVVS-VHWMF-EADPE | HMQHV-JOFXF-XVCOY-UMZZN-RMONC | UULBV-ICFCO-RNVVS-VHWMF-EADPE
    RSWJD-XRROE-UEKER-CWILM-YHUPE | CQORU-RQLKZ-NLYWR-EGCZA-NRTFQ | RSWJD-XRROE-UEKER-CWILM-YHUPE
    TAUKK-MYRLK-ZORLJ-PCJYR-WHAYM | ITQIC-YJTJF-IJFDM-GZUPI-CQJJE | TAUKK-MYRLK-ZORLJ-PCJYR-WHAYM
    VITXK-JGDIH-JAMEC-PXHXE-KHFEX | ZCZCV-GUJQP-TQMQR-ADQYT-NWESG | VITXK-JGDIH-JAMEC-PXHXE-KHFEX
    SYUOJ-ERIVX-KWCRB-YOLPR-LKYCF | SNTDG-ZHMBM-NPSAP-SYLNW-CMHJO | SYUOJ-ERIVX-KWCRB-YOLPR-LKYCF

    Of course, if you wanted to throw in numbers you would just replace the letter with it's index value.

    The way to use this would be something like this:
    • Message codes are generated randomly and stored into a database.
    • The message codes will be encrypted using a random generated key equal to the length of the message
    • The encrypted message is shipped out with a game as a verification code to play it
    • The person who buys the game will enter the verification code into a program to verify if the code is correct
    • The code is then decoded using the shifts from the key
    • If the decoded message doesn't match anything in the database, then the person will not have access to the game

    The first message is RANDOMLY generated, but is stored into a database that isn't public. The verification code is just the message in a RANDOMLY shifted message, which was RANDOMLY shifted by a RANDOMLY generated key holding the values of the shifts. This is what would give the security of verification codes high reputation.

    I have no idea if this is how verification codes are really processed.
    « Last Edit: June 30, 2014, 06:23:45 PM by wildskiller »

    OfflineRuneAgent

    • wololo
    • Member
    • ****
    • *
    • *
    • Posts: 7,515
    • Thanks: +0/-0
      • View Profile
      • MITB FORUMS
    Re: Random code generator
    « Reply #15 on: June 30, 2014, 09:50:33 PM »
    Quote
    This is what would give the security of verification codes high reputation.
    wat.

    OfflineSpecial Air Service

    • Member
    • ***
    • Posts: 103
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #16 on: July 01, 2014, 04:03:38 AM »
    Probably just something you overlooked, but you're clearing your stringbuilder twice for each code you generate! You do this before you start looping  in the generateCode function and after you printed out the code in the main method!

    If you tried it out you would know why there are 2 clears

    OfflineTerraforming

    • Member
    • **
    • Posts: 78
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #17 on: July 01, 2014, 04:32:05 AM »
    Goodjob mate I like it!

    Offlinewildskiller

    • Member
    • ****
    • Posts: 1,435
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #18 on: July 01, 2014, 11:09:57 AM »
    Quote
    This is what would give the security of verification codes high reputation.
    wat.
    Oh just shut it, I was giving an opinion on how verification codes would work better. You probably already know some betters ways I presume?   ;D

    OfflineSnow_

    • Member
    • ***
    • Posts: 161
    • Thanks: +0/-0
      • View Profile
    Re: Random code generator
    « Reply #19 on: July 01, 2014, 12:37:50 PM »
    Probably just something you overlooked, but you're clearing your stringbuilder twice for each code you generate! You do this before you start looping  in the generateCode function and after you printed out the code in the main method!

    If you tried it out you would know why there are 2 clears

    The second sb.delete(0, CHARACTERS); really isn't required.. you remove all the characters once.. and then when they are removed, you remove them again?
    Your logic is flawed, you have to sb.delete(0, CHARACTERS + DASH);

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal