首页 > 解决方案 > 你应该如何使用 PXDBCryptString 属性来解密一个值

问题描述

我在 DAC 中使用以下定义,期望结果在数据库中被加密,但在图形类中的 UI 或代码中显示为解密。我得到的结果是它在 UI 和代码中显示了加密的值。我无法弄清楚我应该如何解密返回的值。

我正在尝试查找有关如何使用此属性的更多信息,但是 2018R1-AcumaticaFramework-DevelopmentGuide.pdf 仅包含稀疏信息。它具有以下链接PXDBCryptLink https://help.acumatica.com/Main?ScreenId=ShowWiki&pageid=176377a7-4d01-786c-a56d-e17ccbf188f0但该链接似乎不再可用。我也无法在 T200 文档中找到任何内容。

有没有人知道如何正确解密使用此属性的值?

提前致谢

    #region C2PAPIKEY
    public abstract class c2PAPIKEY : PX.Data.IBqlField
    {
    }
    protected string _C2PAPIKEY;
    //[PXDBString(50, IsUnicode = true)]
    //not having any luck getting these encryption attributes to work
    //the value coming back is always encrypted regardless of the
    //IsVeiwDecrypted being set to true
    //[PXRSACryptString(50, IsUnicode = true, IsViewDecrypted = true)]
    [PXDBCryptString(50, IsUnicode = true, IsViewDecrypted = true)]
    [PXDefault("")]
    [PXUIField(DisplayName = "Click to Pay API Key")]
    public virtual string C2PAPIKEY
    {
        get
        {
            return this._C2PAPIKEY;
        }
        set
        {
            this._C2PAPIKEY = value;
        }
    }
    #endregion

标签: acumatica

解决方案


我看过一些例子,我相信这个值必须在缓存中显式解密。

这可以使用 RowSelected 事件处理程序在图中完成:

// Make sure DAC is of the type that holds the C2PAPIKEY field
public virtual void DAC_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
    PXDBCryptStringAttribute.SetDecrypted<DAC.c2PAPIKEY>(sender, e.Row, true);
}

推荐阅读