Aleks
asked on
Error in function to encrypt
I am getting an error when trying to encrypt data with a function:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'getEncryptedStringFromDB'
/bluedot/--tempdecrypt--.a sp, line 29
The function is as follow.
the field being encrypted is varchar(100)
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'getEncryptedStringFromDB'
/bluedot/--tempdecrypt--.a
The function is as follow.
<script>
function getEncryptedStringFromDB( str ) {
var cmd = Server.CreateObject("ADODB.Command");
var rs = Server.CreateObject("ADODB.RecordSet");
cmd.ActiveConnection = MM_bluedotjs_STRING;
cmd.CommandText = "dbo.getEncryptedString";
cmd.CommandType = 4;
cmd.CommandTimeout = 0;
cmd.Prepared = true;
cmd.Parameters.Append(cmd.CreateParameter("@LoginId", 3, 1, 4, str));
rs.Open( cmd );
return rs( 0 );
}
</script>
the field being encrypted is varchar(100)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So .. this is my code:
This is the function:
And yes, it is a StoredProcedure (see below). This is the code to create it.
<p>password decrypted : <%=Encryptvb(rs_decryptpassword.Fields.Item("LoginId").Value)%></p>
This is the function:
<script>
function Encryptvb( str ) {
var cmd = Server.CreateObject("ADODB.Command");
var rs = Server.CreateObject("ADODB.RecordSet");
cmd.ActiveConnection = MM_bluedot_STRING;
cmd.CommandText = "dbo.getDecryptedString";
cmd.CommandType = 4;
cmd.CommandTimeout = 0;
cmd.Prepared = true;
cmd.Parameters.Append(cmd.CreateParameter("@LoginId", 3, 1, 4, str));
rs.Open( cmd );
return rs( 0 );
}
</script>
And yes, it is a StoredProcedure (see below). This is the code to create it.
USE [BlueDot]
GO
/****** Object: StoredProcedure [dbo].[getEncryptedString] Script Date: 11/18/2015 15:26:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[getEncryptedString]
@LoginId varchar(max)
as begin
/* create master key encryption by password ='mystrongpassword';
create certificate bluedot with subject = 'bluedot';
create symmetric key bdotpassword with algorithm=triple_des encryption by certificate bluedot;
*/
exec OpenKeys;
declare @result varbinary( 256 );
set @result = dbo.Encryptbdot( @LoginId );
select @result;
end
GO
ASKER
Open in new window
This is my code:
Open in new window
This is for an ASP VBScript page.