A). It is a security protocal between two systems. Lets say we are integration two systems without any encrytion mechanism then hackers will easily hack our information and they will modify the content in very easy manner.
For that they introduced the Cryptography concept and they introduced few algorithms(Cyphercite) for sending secure data between systems or persons.
Generally crypto will convert complete content in encyption format(like alpha numeric integer characters) and one generate key for protection, if you know that key then only you will be able to read that content(after decryption).
In salesforce we have couple of algorithms listed below.
AES128 //Advanced Encryption Standard
AES192
AES256
AES128 :
--------------
Exampe 1:
----------------
Blob exampleIv = Blob.valueOf('Example of IV123');
Blob key = Crypto.generateAesKey(128);
Blob data = Blob.valueOf('how are you fazurulla ??');
Blob encrypted = Crypto.encrypt('AES128', key, exampleIv, data);
system.debug('encrypted******'+EncodingUtil.Base64Encode(encrypted));
Blob decrypted = Crypto.decrypt('AES128', key, exampleIv, encrypted);
String decryptedString = decrypted.toString();
System.debug('Data to be encrypted'+decryptedString);
Example 2:
-----------------
Blob key = Crypto.generateAesKey(128);
Blob data = Blob.valueOf('Generally crypto will convert complete content in encyption format(like alpha numeric integer characters) and one generate key for protection, if you know that key then only you will be able to read that content(after decryption).');
Blob encrypted = Crypto.encryptWithManagedIV('AES128', key, data);
system.debug('*******'+EncodingUtil.Base64Encode(encrypted));
Blob decrypted = Crypto.decryptWithManagedIV('AES128', key, encrypted);
String decryptedString = decrypted.toString();
System.debug('Data to be encrypted'+decryptedString);
Generate Keys :
-------------------
system.debug('key1******'+EncodingUtil.Base64Encode(Crypto.generateAesKey(128)));
system.debug('key2******'+EncodingUtil.Base64Encode(Crypto.generateAesKey(192)));
system.debug('key3******'+EncodingUtil.Base64Encode(Crypto.generateAesKey(256)));
system.debug('Random Integer ::'+Crypto.getRandomInteger());
system.debug('Random Long ::'+Crypto.getRandomLong());
For that they introduced the Cryptography concept and they introduced few algorithms(Cyphercite) for sending secure data between systems or persons.
Generally crypto will convert complete content in encyption format(like alpha numeric integer characters) and one generate key for protection, if you know that key then only you will be able to read that content(after decryption).
In salesforce we have couple of algorithms listed below.
AES128 //Advanced Encryption Standard
AES192
AES256
AES128 :
--------------
Exampe 1:
----------------
Blob exampleIv = Blob.valueOf('Example of IV123');
Blob key = Crypto.generateAesKey(128);
Blob data = Blob.valueOf('how are you fazurulla ??');
Blob encrypted = Crypto.encrypt('AES128', key, exampleIv, data);
system.debug('encrypted******'+EncodingUtil.Base64Encode(encrypted));
Blob decrypted = Crypto.decrypt('AES128', key, exampleIv, encrypted);
String decryptedString = decrypted.toString();
System.debug('Data to be encrypted'+decryptedString);
Example 2:
-----------------
Blob key = Crypto.generateAesKey(128);
Blob data = Blob.valueOf('Generally crypto will convert complete content in encyption format(like alpha numeric integer characters) and one generate key for protection, if you know that key then only you will be able to read that content(after decryption).');
Blob encrypted = Crypto.encryptWithManagedIV('AES128', key, data);
system.debug('*******'+EncodingUtil.Base64Encode(encrypted));
Blob decrypted = Crypto.decryptWithManagedIV('AES128', key, encrypted);
String decryptedString = decrypted.toString();
System.debug('Data to be encrypted'+decryptedString);
Generate Keys :
-------------------
system.debug('key1******'+EncodingUtil.Base64Encode(Crypto.generateAesKey(128)));
system.debug('key2******'+EncodingUtil.Base64Encode(Crypto.generateAesKey(192)));
system.debug('key3******'+EncodingUtil.Base64Encode(Crypto.generateAesKey(256)));
system.debug('Random Integer ::'+Crypto.getRandomInteger());
system.debug('Random Long ::'+Crypto.getRandomLong());