예제 #1
0
 /// <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);
 }
예제 #2
0
 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));
 }
예제 #3
0
        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());
            }
        }
예제 #4
0
 public byte[] AsDecodedBuffer(IEncryptionMethod method)
 {
     ResultStream.Seek(0, SeekOrigin.Begin);
     return(method.Decrypt(AsBuffer()));
 }
예제 #5
0
        public string AsDecodedString(IEncryptionMethod method)
        {
            var retv = Fi.StandardEncoding.GetString(method.Decrypt(AsBuffer()));

            return(retv);
        }
 public DecypherStreamProcessor(IEncryptionMethod method)
 {
     _method = method;
 }
예제 #7
0
 public static String DecryptToBase64(this IEncryptionMethod self, byte[] bytes)
 {
     return(Convert.ToBase64String(self.Decrypt(bytes)));
 }
예제 #8
0
 public SafeObjectStorage(IFileSystem fs, IEncryptionMethod fileEncryptionMethod, IEncryptionMethod dataEncryptionMethod)
 {
     fileSystem    = fs;
     dataEncryptor = dataEncryptionMethod;
     fileEncryptor = fileEncryptionMethod;
 }
예제 #9
0
        /// <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));
        }