SqlServer 2000 sp_OAMethod (wodCrypt)
hI, i was trying to use wodcrypt from inside SqlServer 2000, with sp_OAxxx storeprocedures, but i couldn't. Can anybody helpme? Thats the code in transact sqlserver 2000, and i allways get error.
DECLARE @TXT_TO_CRYPT VARCHAR(4000)
SET @TXT_TO_CRYPT='HOLA MUND0'
DECLARE @hr int
DECLARE @src varchar(255), @desc varchar(255)
/*---------------------------------------------------------------
/ CREA EL OBJETO CRYPT
----------------------------------------------------------------*/
DECLARE @Crypt int
EXEC @hr = sp_OACreate 'WeOnlyDo.wodCryptCom.1', @Crypt OUT,1
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @Crypt, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END
/*---------------------------------------------------------------
/ CREA EL OBJETO DECBLOB
----------------------------------------------------------------*/
DECLARE @DecBlob int
/*EXEC @hr = sp_OACreate 'WeOnlyDo.MemBlob.1', @DecBlob OUT,1
*/
EXEC @hr = sp_OACreate 'WeOnlyDo.MemBlob.1', @DecBlob OUT,1
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @DecBlob, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END
/*---------------------------------------------------------------
/ CREA EL OBJETO ENCBLOB
----------------------------------------------------------------*/
DECLARE @EncBlob int
/*EXEC @hr = sp_OACreate 'WeOnlyDo.MemBlob.1', @EncBlob OUT,1 */
EXEC @hr = sp_OACreate 'WeOnlyDo.MemBlob.1', @EncBlob OUT,1
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @EncBlob, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END
/*------------------------------------------------
/ SETEA PARAMETROS DE LOS OBJETOS
-------------------------------------------------*/
EXEC sp_OASetProperty @DecBlob, 'Text', 'PRUEBA'
EXEC sp_OASetProperty @Crypt , 'Type', 2 /* DES */
EXEC sp_OASetProperty @Crypt , 'SecretKey', 'WeOnlyDo!'
EXEC @hr =sp_OAMethod @Crypt, 'Encrypt', @DecBlob, @EncBlob out
IF @hr <> 0
BEGIN
PRINT 'ERROR METODO ENCRYPT: '+Convert(varchar,@hr)
EXEC sp_OAGetErrorInfo @Crypt, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END
DECLARE @property varchar(4000)
EXEC @hr = sp_OAGetProperty @EncBlob, 'ToBase64', @property OUT
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @EncBlob
RETURN
END
PRINT 'Cifrado: '+@property
exec sp_OADestroy @EncBlob
exec sp_OADestroy @DecBlob
exec sp_OADestroy @Crypt
Complete thread:
- SqlServer 2000 sp_OAMethod - beto21971, 2009-08-21, 05:38
- Re: SqlServer 2000 sp_OAMethod - wodDamir, 2009-08-21, 09:13
- Re: SqlServer 2000 sp_OAMethod - beto21971, 2009-08-21, 23:01
- Re: SqlServer 2000 sp_OAMethod - beto21971, 2009-08-22, 01:23
- Re: SqlServer 2000 sp_OAMethod - beto21971, 2009-08-21, 23:01
- Re: SqlServer 2000 sp_OAMethod - wodDamir, 2009-08-21, 09:13