0

I know there are functions like ENCRYPTBYPASSPHRASE for symmetric encryption but I look for a way in SQL Server to encrypt a field so that I can pass the encrypted string as a part of a URL to the outside world, in a varchar or nvarchar. Actually I don't want the encryption output to be stored in a varbinary field but rather being sit in a nvarchar.

It is OK if the algorithm not being strong, I just need it to put the output in a URL.

Is there any way to achive this?

Farshid
  • 5,134
  • 9
  • 59
  • 87
  • Consider using `Hashing` in that case. – Rahul Jan 18 '16 at 15:47
  • @Rahul I need to decrypted it later. This will be a way for passing the row id in URL – Farshid Jan 18 '16 at 15:47
  • I mean decrypting by the URL interpreter on my web application – Farshid Jan 18 '16 at 15:48
  • Can you try to explain your requirements more clearly? As it sits right now I don't really understand what you are trying to do here. – Sean Lange Jan 18 '16 at 15:52
  • 4
    Store as varbinary then Base64 encode to a string? – Alex K. Jan 18 '16 at 15:52
  • @SeanLange Suppose I have an ID for a row. I want to have a web page URL like x.com/go/ID but I don't want to let users have a pattern for all records like /go/1, /go/2 & so on. Becasue of it, I want to create a URL like /go/hashed instead of /go/1 by passing the URL to the outside having reversable encrypted ID. – Farshid Jan 18 '16 at 16:32
  • I decided to use unique IDs. – Farshid Jan 18 '16 at 16:33
  • 1
    This is an excellent situation for using GUIDs. If you have a uniqueidentifier column in your table you can pass that instead of the ID (I assume identity here). This is simple because it is not easy to guess and doesn't require any extra effort to encode it and decode it. Just a simple where clause takes care of it. – Sean Lange Jan 18 '16 at 16:38
  • Possible duplicate of https://stackoverflow.com/q/12139073/1967612 – Anti-weakpasswords Feb 03 '16 at 05:59

0 Answers0