Click here to Skip to main content
12,753,109 members (39,304 online)
Click here to Skip to main content
Articles » Languages » C# » General » Downloads


29 bookmarked
Posted 15 Oct 2007

Password Safe Database Reader Library in C# for .NET

, 16 Oct 2007 GPL3
An independent library implementation to read Password Safe Password Manager V3 database files
#region License
 *  PasswordSafe Database Reader/Writer
 *  Copyright (C) 2007 Svante Seleborg
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  GNU General Public License for more details.
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <>.
 *  If you'd like to license this program under any other terms than the
 *  above, please contact the author and copyright holder.
 *  Contact:

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace Axantum.PasswordSafe
    /// <summary>
    /// Implements native methods that are safe to call
    /// </summary>
    internal static class SafeNativeMethods
        [DllImport("kernel32.dll", SetLastError = true)]
        static extern int GetACP();

        /// <summary>
        /// Converts the string from Unicode to the current systen Ansi Code Page. This is not really
        /// a good idea, but it's the way PasswordSafe works. Problem is that it can vary from system
        /// to system, and then you can't open your database... :-(.
        /// </summary>
        /// <param name="passphrase">The passphrase.</param>
        /// <returns>The passphrase encoded in the current system Ansi Code Page</returns>
        public static byte[] ConvertString(string passphrase)
            return Encoding.GetEncoding(GetACP()).GetBytes(passphrase);

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Svante Seleborg
Web Developer Axantum Software AB
Sweden Sweden
I've been working with all aspects of software development since 1979 - from compiler construction to management. Currently I'm an independent consultant mostly specializing in computer security. Please see my homepage for contact details.

I speak C like a native, and have a pretty good grasp of C++. The most recent five years C# has been the main development language. Traditionally Unix has been the dominating environment, but currently the scales have tipped over to Windows, due to market demands but I'm equally at home developing in both environments.

When I'm not coding I'm usually sitting on one of my 4 bikes, indoors or outdoors, on the road or in the woods.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 16 Oct 2007
Article Copyright 2007 by Svante Seleborg
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid