コード例 #1
0
        /// <summary>
        /// Returns a platform-specific algorithm that conforms to the prescribed platform-neutral algorithm.
        /// </summary>
        /// <param name="algorithm">The PCL algorithm.</param>
        /// <returns>
        /// The platform-specific algorithm.
        /// </returns>
        private static Platform.SymmetricAlgorithm GetAlgorithm(SymmetricAlgorithm algorithm)
        {
            #if SILVERLIGHT || __IOS__
            switch (algorithm)
            {
                case SymmetricAlgorithm.AesCbcPkcs7:
                    return new Platform.AesManaged();
                default:
                    throw new NotSupportedException();
            }
            #else
            Platform.SymmetricAlgorithm platform = Platform.SymmetricAlgorithm.Create(
                algorithm.GetName().GetString());
            if (platform == null)
            {
                throw new NotSupportedException();
            }

            platform.Mode = GetMode(algorithm);
            platform.Padding = GetPadding(algorithm);

            return platform;
            #endif
        }