How to Encrypt Column in SQL Server?

Hi all,
I am using ColdFusion MX 7 and Microsoft SQL Server 2000
database. I have a column that contains social security numbers of
my users and am feeling the need to encrypt that column.
Trouble is, I have no clue how to do this in SQL Server or
how I could display the data from that column in my web app once
the column is encrypted.
Can anyone offer any suggestions?
Thanks in advance!

Here's one way...
To encrypt:
URLEncodedFormat(Encrypt(yourSStoencrypt,
application.encKey)) then
store this value in MSSQL
To decrypt:
Decrypt(URLDecode(yourSStodecryptfromDB), application.encKey)
HTH
Tim Carley
www.recfusion.com
[email protected]

Similar Messages

  • How to convert rows to columns in sql server 2008

    How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)

    Lookup the Pivot transformation. From BOL:
    The Pivot transformation makes a normalized data set into a less normalized
    but more compact version by pivoting the input data on a column value. For
    example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
    details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
    single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
    null values.
    When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
    The column is passed through unchanged to the output. Because many input rows
    can result only in one output row, the transformation copies only the first
    input value for the column.
    The column acts as the key or part of the key that identifies a set of
    records.
    The column defines the pivot. The values in this column are associated with
    columns in the pivoted dataset.
    The column contains values that are placed in the columns that the pivot
    creates.
    Paul

  • How to encrypt column of some table with the single method ?

    How to encrypt column of some table with the single method ?

    How to encrypt column of some table with the single
    method ?How to encrypt column of some table with the single
    method ?
    using dbms_crypto package
    Assumption: TE is a user in oracle 10g
    we have a table need encrypt a column, this column SYSDBA can not look at, it's credit card number.
    tha table is
    SQL> desc TE.temp_sales
    Name Null? Type
    CUST_CREDIT_ID NOT NULL NUMBER
    CARD_TYPE VARCHAR2(10)
    CARD_NUMBER NUMBER
    EXPIRY_DATE DATE
    CUST_ID NUMBER
    1. grant execute on dbms_crypto to te;
    2. Create a table with a encrypted columns
    SQL> CREATE TABLE te.customer_credit_info(
    2 cust_credit_id number
    3      CONSTRAINT pk_te_cust_cred PRIMARY KEY
    4      USING INDEX TABLESPACE indx
    5      enable validate,
    6 card_type varchar2(10)
    7      constraint te_cust_cred_type_chk check ( upper(card_type) in ('DINERS','AMEX','VISA','MC') ),
    8 card_number blob,
    9 expiry_date date,
    10 cust_id number
    11      constraint fk_te_cust_credit_to_cust references te.customer(cust_id) deferrable
    12 )
    13 storage (initial 50k next 50k pctincrease 0 minextents 1 maxextents 50)
    14 tablespace userdata_Lm;
    Table created.
    SQL> CREATE SEQUENCE te.customers_cred_info_id
    2 START WITH 1
    3 INCREMENT BY 1
    4 NOCACHE
    5 NOCYCLE;
    Sequence created.
    Note: Credit card number is blob data type. It will be encrypted.
    3. Loading data encrypt the credit card number
    truncate table TE.customer_credit_info;
    DECLARE
    input_string VARCHAR2(16) := '';
    raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    key_string VARCHAR2(8) := 'AsDf!2#4';
    raw_key RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(key_string,'AL32UTF8','US7ASCII'));
    encrypted_raw RAW(2048);
    encrypted_string VARCHAR2(2048);
    BEGIN
    for cred_record in (select upper(CREDIT_CARD) as CREDIT_CARD,
    CREDIT_CARD_EXP_DATE,
    to_char(CREDIT_CARD_NUMBER) as CREDIT_CARD_NUMBER,
    CUST_ID
    from TE.temp_sales) loop
    dbms_output.put_line('type:' || cred_record.credit_card || 'exp_date:' || cred_record.CREDIT_CARD_EXP_DATE);
    dbms_output.put_line('number:' || cred_record.CREDIT_CARD_NUMBER);
    input_string := cred_record.CREDIT_CARD_NUMBER;
    raw_input := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    dbms_output.put_line('> Input String: ' || CONVERT(UTL_RAW.CAST_TO_VARCHAR2(raw_input),'US7ASCII','AL32UTF8'));
    encrypted_raw := dbms_crypto.Encrypt(
    src => raw_input,
    typ => DBMS_CRYPTO.DES_CBC_PKCS5,
    key => raw_key);
    encrypted_string := rawtohex(UTL_RAW.CAST_TO_RAW(encrypted_raw)) ;
    dbms_output.put_line('> Encrypted hex value : ' || encrypted_string );
    insert into TE.customer_credit_info values
    (TE.customers_cred_info_id.nextval,
    cred_record.credit_card,
    encrypted_raw,
    cred_record.CREDIT_CARD_EXP_DATE,
    cred_record.CUST_ID);
    end loop;
    commit;
    end;
    4. Check credit card number script
    DECLARE
    input_string VARCHAR2(16) := '';
    raw_input RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(input_string,'AL32UTF8','US7ASCII'));
    key_string VARCHAR2(8) := 'AsDf!2#4';
    raw_key RAW(128) := UTL_RAW.CAST_TO_RAW(CONVERT(key_string,'AL32UTF8','US7ASCII'));
    encrypted_raw RAW(2048);
    encrypted_string VARCHAR2(2048);
    decrypted_raw RAW(2048);
    decrypted_string VARCHAR2(2048);
    cursor cursor_cust_cred is select CUST_CREDIT_ID, CARD_TYPE, CARD_NUMBER, EXPIRY_DATE, CUST_ID
    from TE.customer_credit_info order by CUST_CREDIT_ID;
    v_id customer_credit_info.CUST_CREDIT_ID%type;
    v_type customer_credit_info.CARD_TYPE%type;
    v_EXPIRY_DATE customer_credit_info.EXPIRY_DATE%type;
    v_CUST_ID customer_credit_info.CUST_ID%type;
    BEGIN
    dbms_output.put_line('ID Type Number Expiry_date cust_id');
    dbms_output.put_line('-----------------------------------------------------');
    open cursor_cust_cred;
    loop
         fetch cursor_cust_cred into v_id, v_type, encrypted_raw, v_expiry_date, v_cust_id;
    exit when cursor_cust_cred%notfound;
    decrypted_raw := dbms_crypto.Decrypt(
    src => encrypted_raw,
    typ => DBMS_CRYPTO.DES_CBC_PKCS5,
    key => raw_key);
    decrypted_string := CONVERT(UTL_RAW.CAST_TO_VARCHAR2(decrypted_raw),'US7ASCII','AL32UTF8');
    dbms_output.put_line(V_ID ||' ' ||
    V_TYPE ||' ' ||
    decrypted_string || ' ' ||
    v_EXPIRY_DATE || ' ' ||
    v_CUST_ID);
    end loop;
    close cursor_cust_cred;
    commit;
    end;
    /

  • How to secure connection in sql server 2008? my main problem is which certificate should i add in mmc

    i'm recently working on hardening of sql server 2008. now i face with a problem. my problem is  how to secure connection in sql server 2008?  my main problem is which certificate should i add in mmc? what are these certificates about?and guide
    me in choosing the appropriate certificate.
    and how should i know that the connection in sql server is secured?
    plz guide me from the beginning cause i'm rookie in this subject.
    thanks in advance.

    Hi sqlfan,
    Question 1: my problem is how to secure connection in sql server 2008?
    Microsoft SQL Server can use Secure Sockets Layer (SSL) to encrypt data that is transmitted across a network between an instance of SQL Server and a client application. For more information about Encrypting Connections to SQL Server, please refer to the following
    article:
    http://technet.microsoft.com/en-us/library/ms189067(v=sql.105).aspx
    Question 2: my main problem is which certificate should i add in mmc? what are these certificates about?and guide me in choosing the appropriate certificate.
    To install a certificate in the Windows certificate store of the server computer, you will need to purchase/provision a certificate from a certificate authority first. So please go to a certificate authority to choose the appropriate certificate.
    For SQL Server to load a SSL certificate, the certificate must meet the following conditions:
    The certificate must be in either the local computer certificate store or the current user certificate store.
    The current system time must be after the Valid from property of the certificate and before the Valid to property of the certificate.
    The certificate must be meant for server authentication. This requires the Enhanced Key Usage property of the certificate to specify Server Authentication (1.3.6.1.5.5.7.3.1).
    The certificate must be created by using the KeySpec option of AT_KEYEXCHANGE. Usually, the certificate's key usage property (KEY_USAGE) will also include key encipherment (CERT_KEY_ENCIPHERMENT_KEY_USAGE).
    The Subject property of the certificate must indicate that the common name (CN) is the same as the host name or fully qualified domain name (FQDN) of the server computer. If SQL Server is running on a failover cluster, the common name must match the host
    name or FQDN of the virtual server and the certificates must be provisioned on all nodes in the failover cluster.
    Question 3: how should i know that the connection in sql server is secured?
    If the certificate is configured to be used, and the value of the ForceEncryption option is set to Yes, all data transmitted across a network between SQL Server and the client application will be encrypted using the certificate. For more detail about this,
    please refer to Configuring SSL for SQL Server in the following article:
    http://technet.microsoft.com/en-us/library/ms189067(v=sql.105).aspx
    If you have any question, please feel free to let me know.
    Regards,
    Donghui Li

  • How can I connect to SQL Server CE?

    Hi!
    How can I connect to SQL Server CE ?
    Any idea?
    I found jdbc driver for SQL Server 6.5,7.0,2000.
    But no driver for SQL CE.
    Thanks for any suggestion....

    I am also searching for same answer.
    I wanna choose Access as a db. but I can't find that so I have a no choice to select SQL2000CE though.
    I am stuck in driver problem. I can't find that.
    Should I use Oracle Lite or PointBase?
    I am under a lot of stress... like you've been...
    I wish you find and post that....

  • How do i connect to sql server 2012 from cmd .

    Hi ,
    I Installed sql server 2008 R2 and 2012 Express and sql server2014 . I can conect to sql server 2008 R2 using
    SQLCMD -L command .
    How do i connect to sql server 2012 express edition from cmd .
    Any Hep appreciated
    Thanks in advance,
    Shravan

    I HAVE ANOTHER INSTANCE NAMED TEST  WHEN I USE THE COMMAND IT GIVES ME THIS ERROR 
    HOW TO RECTIFY 
    C:\Users\HP>SQLCMD -S HP-HP/TEST
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: C
    ould not open a connection to SQL Server [67]. .
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
    Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or in
    stance-specific error has occurred while establishing a connection to SQL Server
    . Server is not found or not accessible. Check if instance name is correct and i
    f SQL Server is configured to allow remote connections. For more information see
     SQL Server Books Online..
    PLZ HELP 

  • How to connect to a Sql server from Oracle using db link

    Hi All,
    Does anybody have any idea about how to connect to a sql server from oracle database using db link to syncronize the data? I need to pull the data from Sql server table to Oracle tables and relay messages back to the sql server.
    Thank you,
    Praveen.

    we have 2 products - DG4MSQL and DG4ODBC.
    DG4ODBC is for free and requires a 3rd party ODBC driver and it can connect to any 3rd party database as long as you use a suitable ODBC driver
    DG4MSQL is more powerfull as it is designed for MS SQL Server databases and it supports many functions it can directly map to SQL Server equivalents - it can also call remote procedures or participtae in distributed transactions. Please be aware DG4MSQL requires a license - it is not for free.
    Check out Metalink and you'll find notes how to configure both products.
    For a generic overview:
    Note.233876.1 Options for Connecting to Foreign Data Stores and Non-Oracle Databases
    And the setup notes:
    DG4ODBC
    Note.561033.1 How to Setup DG4ODBC on 64bit Unix OS (Linux, Solaris, AIX, HP-UX) :
    Note.466225.1 How to Setup DG4ODBC (Oracle Database Gateway for ODBC) on Windows 32bit RDBMS.HS-3-2 :
    Note.109730.1 How to setup generic connectivity (HSODBC) for 32 bit Windows (Windows NT, Windows 2000, Windows XP, Windows 2003) V817:
    Note.466228.1 How to Setup DG4ODBC on Linux x86 32bit
    DG4MSQL
    Note.466267.1 How to Setup DG4MSQL (Database Gateway for MS SQL Server) on Windows 32bit
    Note.562509.1 How to Setup DG4MSQL (Oracle Database Gateway for MS SQL Server) 64bit Unix OS (Linux, Solaris, AIX,HP-UX)
    Note.437374.1 How to Setup DG4MSQL (Oracle Database Gateway for MS SQL Server) Release 11 on Linux

  • How to encrypt column of some table with the single method  on oracle7/814?

    How to encrypt column of some table with the single method on oracle7/814?

    How to encrypt column of some table with the single method on oracle7/814?

  • Desc doesn't show datetime columns from SQl Server

    Hi Everyone,
    I have working db link to sql server using hsodbc:
    Oracle 10.2 on AIX using freetds odbc driver version 0.82.
    I can access tables on sql server but oracle sees only varchars and numerics columns in a table.
    Is there a way to select datetime columns from sql server using hsodbc?

    when hsodbc does not show a certain data type it is commonly related to the fact that HSODBC doesn't support the related ODBC data type.
    In general you have a data type in your SQL Server which is mapped to an ODBC data type by the ODBC driver. HSODBC then maps the ODBC data type to an Oracle equivalent and when the ODBC data type isn't supported by HSODBC it just drops it from the select list.
    So for a root cause analysis an ODBC trace is required to determine the mapping of the FreeTDS ODBC driver.
    With this info we can then compare the mapping documented in the HSODBC manual and if the ODBC data type isn't listed as a supported data type you then need to cast the data type on the source side to a different data type (for example varchar/char).
    So please post the ODBC trace and I'll have a look.
    - Klaus
    Edited by: kgronau on Apr 2, 2013 12:50 PM
    BTW, here the link to the HSODBC docu:
    http://docs.oracle.com/cd/B19306_01/server.102/b14232.pdf
    Oracle® Database
    Heterogeneous Connectivity Administrator's Guide
    10g Release 2 (10.2)
    B14232-01
    B.1 Mapping ANSI Data Types to Oracle Data Types Through an ODBC
    Interface

  • How to select data from Sql server 2005 database tableinto oracle database table

    Hi,
    I have table text1 in sql server database and text2 in oracle database (11g). Now how to move data from SQL Server table into oracle table. So please help me how to do it.
    Thanks a lot in advance.
    rk
    OS: Windows 7 professional

    Hi,
    you can use export/import wizard and specify sql server as a source and oracle as destination.
    I hope this is helpful.
    Please Mark it as Answered if it answered your question
    OR mark it as Helpful if it help you to solve your problem
    Elmozamil Elamir Hamid
    MCSE Data Platform
    MCITP: SQL Server 2008 Administration/Development
    MCSA SQL Server 2012
    MCTS: SQL Server Administration/Development
    MyBlog

  • What is Oracle's alternative to IDENTITY Column in SQL Server/ DB2

    What is Oracle's alternative to IDENTITY Column(Auto Increment Column) in SQL Server/ DB2 ? Is Sequence and Trigger the only way out for this?
    Why is Oracle not creating anything like an Identitiy column in SQL Server?

    What is Oracle's alternative to IDENTITY Column(Auto
    Increment Column) in SQL Server/ DB2 ? Is Sequence
    and Trigger the only way out for this?Of course not, you can use in your inserts sequences as well:
    insert into blahh values (my_seq.nextval, ...) and use returniong clause to get the value back if necessary
    You can use them in insert with subselects
    insert into blah
    select my_seq.nextval, ...
    from ....
    >
    Why is Oracle not creating anything like an Identitiy
    column in SQL Server?Because they are different companies with different people and thoughts and existing mechanism is sufficient i.e. one can even argue that it is even more flexible than identity btw ;)
    Gints Plivna
    http://www.gplivna.eu

  • How to repair database using SQL server 2008 and C#

    How to repair database in SQL server 2008 using C#
    Musakkhir Sayyed.

    Unfortunately your post is off topic as it's not specific to SQL Server Samples and Community Projects.  
    This is a standard response I’ve written in advance to help the many people who post their question in this forum in error, but please don’t ignore it.  The links I provide below will help you determine the right forum to ask your
    question in.
    For technical issues with Microsoft products that you would run into as an end user, please visit the Microsoft Answers forum ( http://answers.microsoft.com ) which has sections for Windows, Hotmail,
    Office, IE, and other products.
    For Technical issues with Microsoft products that you might have as an IT professional (like technical installation issues, or other IT issues), please head to the TechNet Discussion forums at http://social.technet.microsoft.com/forums/en-us, and
    search for your product name.
    For issues with products you might have as a Developer (like how to talk to APIs, what version of software do what, or other developer issues), please head to the MSDN discussion forums at http://social.msdn.microsoft.com/forums/en-us, and
    search for your product or issue.
    If you’re asking a question particularly about one of the Microsoft Dynamics products, a great place to start is here: http://community.dynamics.com/
    If you think your issue is related to SQL Server Samples and Community Projects and I've flagged it as Off-topic, I apologise.  Please repost your question and include as much detail as possible about your problem so that someone can assist you further. 
    If you really have no idea where to post your question please visit the Where is the forum for…? forum http://social.msdn.microsoft.com/forums/en-us/whatforum/
    When you see answers and helpful posts, please click Vote As Helpful,
    Propose As Answer, and/or Mark As Answer
    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCSA, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID:
    Microsoft Transcript

  • How to attach database in sql server 2005 restricted mode

    hi i have a database i want once i have attach database in sql server 2005, anyone cannot do detach, script and delete my database except myself. I mean i want to secure my database to avoid unauthorized persons access
    how it is possible in sql server 2005 express management studio

    There are restrictions for normal Logins but a administrator in SQL server can always detach,script and delete your database.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • How to register VSPackage into SQL Server Management Studio?

    Hi All,
    I am a newer to VSPackage, I want to create a VSPackage for SQL Server Management Studio(SSMS), now I can create a VSPackage project and debug it in Visual Studio but don't know how to debug it in SQL Server Management Studio and how to deploy VSPackage to
    SSMS by MSI? Thanks

    By the way I find a extension.vsixmanifest file and some .pkgdef files under
    C:\Program Files\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Extensions\  folder, and they are very similar with VSPackage files. Do know this is useful or not.
    Hi Vic Zhang,
    After some research, There are some notes. SQL Server Management Studio is built upon the Visual Studio Isolated Shell, which inherently supports extensibility (add-ins/plug-ins). It is possible to tap into the Visual Studio extensibility services to surface
    custom capabilities within SQL Server Management Studio; however, we do not discourage this, keep in mind that such extensibility is not supported, so there may be issues with backward/forward compatibility. Microsoft does not publish documentation for extending
    SQL Server Management Studio.
    If you want to debug VSPackeage about SSMS, I recommend you debug in Visual Studio and not in SSMS, open the project and attach to the process of SSMS.exe, then debug it.
    About the issue of finding the “RootKey”, a .pkgdef file is way to encapsulate application configuration information in an easily editable, distributable, and deployable form. And it registers the Extension Manager (which is written as a VS Package). If
    you install SQL Server 2012, the .pkgdef of SSMS is located in the following path, you can check the “RootKey” in this .pkgdef file.
    C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio
    There is detail about a PkgDef, you can review the following article.
    http://blogs.msdn.com/b/visualstudio/archive/2009/12/18/what-s-a-pkgdef-and-why.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How to Open Or read SQL Server log file .ldf

    Hi all,
    How to Open Or read SQL Server log file .ldf
    When ever we create database from sql server, it's create two file. (1) .mdf (2) .ldf.
    I want to see what's available inside the .ldf file.
    Thanks,
    Ashok

    I am not too sure but may be the below two undocumented commands might yield the desired result.
    DBCC Log
    Fn_dblog function
    Refer these links for more info,
    http://www.mssqlcity.com/Articles/Undoc/SQL2000UndocDBCC.htm
    http://blogs.sqlserver.org.au/blogs/greg_linwood/archive/2004/11/27/37.aspx
    http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1173464,00.html
    Some 3rd party tools like Log Explorer can do the job for you.
    http://www.lumigent.com/products/le_sql.html
    - Deepak

Maybe you are looking for

  • What is happening with my Macs these days???

    Okay, two different Macs, both loaded with TONS of multi-media apps and supporting tech. One is a dual G5 and the other a 17" Macbook Pro. Both with the latest updates of everything I actively use. So, here are the issues I'm SUFFERING lately. MAIL:

  • HT2998 mini mac with Panasonic TV

    I am considering on buying an mini mac,  to conserve space using my tv as a monitor,  can the mini mac hook up to my tv (panasomic smart viera)?

  • Adapters used in PI

    Hi All, I am new to PI. I want to learn PI. Can ny1 tel me hw many adapters are there?? and when do we use whch adapter?? how many scenarios are there??? when to use which scenario???? Regards, Rashmi.

  • Scritical scenarious and critical threads

    Iam attending an interview after 2 days could anyone send me real time scenarios in GL,AP,AR please to this id [email protected] please help me ..i will reward this points.. its very urgent ..hope to see some replys to my email id thanks in advance

  • Can I switch language to english, in a Spanish Leopard version?

    I am intending to upgrade to Leopad finally, but i have an issue before do it so. The only copy I can get is a spanish version, and my powerbook comes with english version Tiger. Would I be able to switch language during installation, and keep englis