Documentation Center

Upgrading to hashed passwords

Audience Manager ships with sample Web pages that implement a simple subscription model. The sample Web pages in the previous version stored passwords in plain text. Since it is not best practice to store passwords in plain text, in Audience Manager 2013 new utility methods have been added to the APIs so that you can encrypt passwords using one-way hash values. The sample Web pages have been updated to use these methods.

Converting plain text passwords to hash values
The Audience Manager API (.NET) provides access to Audience Manager item types (Contacts and Segments) on the Content Manager. If you already have Contacts with plain text passwords, you can convert these passwords to one-way hash values using the DigestPassword() and CheckPassword() methods in the Tridion.AudienceManagement.API namespace.
To upgrade Contacts that have a password (and ignore passwords that are empty):
var someAddressBook = new StaticAddressBook(new TcmUri(addressBookId), userContext);
IEnumerable<Contact> contacts = Contact.GetContacts(userContext, new ContactFilter(userContext), someAddressBook);
foreach (var contact in contacts)
{
	contact.ReloadReadOnlyContact(); // Fully load the contact 
	string password = (string)contact.ExtendedDetails["password"].Value;

	if (password == null) continue;

	password = Digests.DigestPassword(password);
	contact.ExtendedDetails["password"].Value = password;
	contact.Save();
}
Encrypting passwords to hash values
If your Web site uses Java, encrypt passwords using the DigestPassword() and CheckPassword() methods in the com.tridion.marketingsolution.utilities package (Outbound E-mail Content Delivery (Java) API).
If your Web site uses .NET, encrypt passwords using the DigestPassword() and CheckPassword() methods in the Tridion.OutboundEmail.ContentDelivery.Utilities namespace (Outbound E-mail Content Delivery (.NET) API).