/// <summary> /// create enc method instance /// </summary> /// <returns>object</returns> internal static IEncryptionMethod EncryptionMethod() { if (_cipherMethod == null) { string locationTypeName = System.Configuration.ConfigurationManager.AppSettings["ciphermethodclass"].ToString(); Type type = Type.GetType(locationTypeName); _cipherMethod = (IEncryptionMethod)Activator.CreateInstance(type); } return(_cipherMethod); }
public static byte[] Encrypt(this IEncryptionMethod self, string inputString) { byte[] bytes; if (inputString.IsBase64()) { bytes = Convert.FromBase64String(inputString); } else { bytes = Fi.StandardEncoding.GetBytes(inputString); } return(self.Encrypt(bytes)); }
public static void EncryptionMethod(ID3v2TagVersion tagVersion, bool useData) { if (tagVersion == ID3v2TagVersion.ID3v22) { throw new NotSupportedException(); } IID3v2Tag id3 = new ID3v2Tag(); IEncryptionMethod aud = id3.EncryptionMethodList.AddNew(); using (MemoryStream ms = new MemoryStream()) { Write(ms, Encoding.ASCII.GetBytes("http://owneridentifier.org")); ms.WriteByte(0); // terminate ms.WriteByte(0x95); // method symbol if (useData) { Write(ms, new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04 }); } TestFrame(aud, tagVersion, ms.ToArray()); } }
public byte[] AsDecodedBuffer(IEncryptionMethod method) { ResultStream.Seek(0, SeekOrigin.Begin); return(method.Decrypt(AsBuffer())); }
public string AsDecodedString(IEncryptionMethod method) { var retv = Fi.StandardEncoding.GetString(method.Decrypt(AsBuffer())); return(retv); }
public DecypherStreamProcessor(IEncryptionMethod method) { _method = method; }
public static String DecryptToBase64(this IEncryptionMethod self, byte[] bytes) { return(Convert.ToBase64String(self.Decrypt(bytes))); }
public SafeObjectStorage(IFileSystem fs, IEncryptionMethod fileEncryptionMethod, IEncryptionMethod dataEncryptionMethod) { fileSystem = fs; dataEncryptor = dataEncryptionMethod; fileEncryptor = fileEncryptionMethod; }
/// <summary> /// invoke enc method /// </summary> /// <param name="message">unencr message</param> /// <returns>enc message</returns> public static string Encryption(string message) { IEncryptionMethod instance = CipherFactory.EncryptionMethod(); return(instance.Encryption(message)); }