internal static CryptoSignResponse ConvertToCryptoSignResponse(this encryptResponse response) { if (response == null || response.@return == null) { return(new CryptoSignResponse()); } return(new CryptoSignResponse([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])); }
public string Cifrar(ref authTokenType token, string texto, string alias) { LunaXml.xmCryptoService client = new xmCryptoService(); try { encrypt en = new encrypt(); en.DataToEncrypt = texto; en.AuthToken = token; en.EncryptionKeyAlias = alias; en.Mechanism = MechanismType.CBC; en.Padding = paddingType.PKCS5Padding; en.Parameter = new[] { new ParameterType() { ParameterName = "IV", ParameterValue = "MTIzNDU2Nzg=" } }; encryptResponse res = client.encrypt(en); token = res.AuthToken; if (res.Result.ResultMajor != null && res.Result.ResultMajor == "urn:oasis:names:tc:dss:resultmajor:Success") { return(res.EncryptedData); } else { Log.Error((res.Result.ResultMessage != null ? res.Result.ResultMessage.Value : "")); return(null); } } catch (Exception ex) { Log.Error("Error al intentar firmar: " + ex); return(null); } finally { client.Dispose(); } }