Skip to content

Cryptography for arrays and strings.

Rafał Mikrut requested to merge github/fork/Catprog/crypto into master

Created by: Catprog

Encryption, Decryption for strings and raw arrays. HMAC for raw_Arrays


    var enc = Crypto.new();



    var key = [0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1];

    enc.SetKey(key);

    var encrypted = enc.EncryptString("Test123",true)
    var cnt = 0;
    var buf = "";

    for i in encrypted:
        cnt = cnt + 1;

        buf = buf +  str(i) + " ";

        if(cnt == 16):
            cnt =0;
            buf = buf + "\n"


    print (buf);    

    print ('----');
    print( enc.DecryptString(encrypted,true))

    print ('*****************');    
    var encrypted = enc.EncryptRaw([100,90,80],true)
    var cnt = 0;
    var buf = "";

    for i in encrypted:
        cnt = cnt + 1;

        buf = buf +  str(i) + " ";

        if(cnt == 16):
            cnt =0;
            buf = buf + "\n"


    print (buf);

    print ('----');

    var decrypted = enc.DecryptRaw(encrypted,true)
    var cnt = 0;
    var buf = "";

    for i in decrypted:
        cnt = cnt + 1;

        buf = buf +  str(i) + " ";

        if(cnt == 16):
            cnt =0;
            buf = buf + "\n"


    print (buf);

Merge request reports