code_junkie

Compatible encryption between C# and PHP, ColdFusion, Ruby, Python

Nov 11th, 2011
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. function XOREncryption($InputString, $KeyPhrase){
  2.  
  3. $KeyPhraseLength = strlen($KeyPhrase);
  4.  
  5. for ($i = 0; $i < strlen($InputString); $i++){
  6.  
  7. $rPos = $i % $KeyPhraseLength;
  8.  
  9. $r = ord($InputString[$i]) ^ ord($KeyPhrase[$rPos]);
  10.  
  11. $InputString[$i] = chr($r);
  12. }
  13.  
  14. return $InputString;
  15. }
  16.  
  17. Key = generateSecretKey( 'AES' , 128 )
  18.  
  19. EncryptedText = encrypt( Text , Key , 'AES' , 'Hex' )
  20.  
  21. Text = decrypt( EncryptedText , Key, 'AES' , 'Hex' )
  22.  
  23. <cfset var strHash = Hash(arguments.hashstring,"SHA-256") />
  24.  
  25. hash('sha256', $strKey);
  26.  
  27. byte[] data = new byte[DATA_SIZE];
  28. byte[] result;
  29. SHA256 shaM = new SHA256Managed();
  30. result = shaM.ComputeHash(data);
Add Comment
Please, Sign In to add comment