1
Creating public links programatically - password hashing?
Question asked by Mike Eldridge - 3/4/2015 at 8:57 PM
Answered
I have a need to automatically create public links.  Looking at the database, there is a PublicLink table with a very sane and mostly self-explanatory structure.  The one snag is the password column.  I would like the option to set a password on the public links I create, but I'm not quite sure what the hashing method used here is.  Is it SHA-256?  Is it salted?
 
Thanks in advance.

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post Marked As Answer
If you only need the password creation part you can call this function (by referencing GleamTech.FileVista.dll):
 
var passwordForDB = CryptoManager.CreatePassword("password");
Also it's possible to create a public link directly by calling a built-in function.
If you can put your code in the same application (like a new aspx file under FileVista folder), you can use this function from the static DataContext object:
 
var publicLinkId = ApplicationContext.DataContext.CreatePublicLink(userId, rootFolderId, folder.Path, fileName, nameForUrl, false, forceSave, expirationTime, hitLimit, password);
If not then you can always create an instance of DataContext object and call the same function from a separate application:
 
//Replace Provider and ConnectionString with values from your FileVista.config
var dataContext = new DataContext("Provider", "ConnectionString");
var publicLinkId = dataContext.CreatePublicLink(userId, rootFolderId, folder.Path, fileName, nameForUrl, false, forceSave, expirationTime, hitLimit, password);
 

Reply to Thread