/// <summary> /// Encrypt encript method implementation /// </summary> public static string Encrypt(string plainStr, string KeyString) { if (plainStr.StartsWith("0x01")) { return(plainStr); } string cipherText = CipherUtility.Encrypt <AesManaged>(plainStr, KeyString, "BABE"); return("0x01" + cipherText); }
/// <summary> /// Decrypt method implementation /// </summary> public static string Decrypt(string encryptedText, string KeyString) { if (!encryptedText.StartsWith("0x01")) { throw new SharePointIdentityCryptographicException("Message Unknown ! or never never encrypted by SharePoint Indentity Service !"); } encryptedText = encryptedText.Substring(4); string cipherText = CipherUtility.Decrypt <AesManaged>(encryptedText, KeyString, "BABE"); return(cipherText); }