Skip to content

Instantly share code, notes, and snippets.

@harsh-2024
Created August 11, 2023 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harsh-2024/694f219042a80e09ccb5c0cebc9b906a to your computer and use it in GitHub Desktop.
Save harsh-2024/694f219042a80e09ccb5c0cebc9b906a to your computer and use it in GitHub Desktop.
Encryption handler
void main() {
final plainText = 'laiba123@A';
final key = Key.fromUtf8('kf;WtH}yb/zTo!H=9}DIoS?2{_V&b/md');
final iv = IV.fromLength(16);
final encrypter = Encrypter(AES(key, mode: AESMode.ecb));
final encrypted = encrypter.encrypt(plainText, iv: iv);
final decrypted = encrypter.decrypt(encrypted, iv: iv);
print(decrypted);
print(encrypted.base64);
}
const CryptoJS = require('crypto-js');
const plainText = 'laiba123@A';
const key = CryptoJS.enc.Utf8.parse('kf;WtH}yb/zTo!H=9}DIoS?2{_V&b/md');
const iv = CryptoJS.lib.WordArray.random(16);
const cipherParams = CryptoJS.AES.encrypt(plainText, key, {
iv: iv,
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
});
const encryptedText = cipherParams.toString();
console.log('Encrypted: ' + encryptedText);
const decryptedBytes = CryptoJS.AES.decrypt(cipherParams, key, {
iv: iv,
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
});
const decryptedText = decryptedBytes.toString(CryptoJS.enc.Utf8);
console.log('Decrypted: ' + decryptedText);
import secrets
import string
def generate_random_string(length):
characters = string.ascii_letters + string.digits + string.punctuation
random_string = ''.join(secrets.choice(characters) for _ in range(length))
return random_string
random_string = generate_random_string(32)
print(random_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment