In its time, the Hungarian National Bank--housed in an imposing gray stone building regally appointed with marble interior paneling and polished brass banisters--has withstood wars, revolution and financial collapse.

So it is not surprising that the bankers who work there express guarded optimism that the bank also will come through the latest crisis, the "credit crunch" of 1982, with its reputation for financial skill intact.

Officials insist as diplomatically as they can that Hungary's finances should not be lumped together with those of its Soviet Bloc allies Poland and Romania, whose unpaid bills and $38 billion in debts are a major worry for the international financial system.

"The situation is creating a strain on our reserves," acknowledged Gyula Czirjak, the bank's general manager. But he added, "We are in a position to continue making normal payments on our loans."

Hungarian bankers expect the Reagan administration to support their pending application for membership in the International Monetary Fund. This approval, they say, should buttress the confidence of Western banks in the soundness of Hungary's economy and financial system.

Even so, officials concede that the economic and political shocks of the last year have tied Hungary's financial future to events largely beyond its control.

Nearly one-fifth of the entire economy now depends on trade with non-Communist countries. This means that the continuing recession in the West hits hard at Hungary at a time when exports to the West are needed to help pay the $583 million in debt coming due this year.

Mounting tensions between the United States and the Soviet Union add more uncertainty.

Western banks and companies, which were extremely nervous about Soviet Bloc indebtedness even before martial law was imposed in Poland, now are even more worried about the impact on East-West trade of economic sanctions being pushed by the Reagan administration.

Hungary's last major Western loan was a $140 million credit in British pounds approved by a syndicate in London Jan. 26. This loan was to finance chemical imports.

Since then, Western bankers have told their Hungarian counterparts to forgo for the time being trying to raise larger, unrestricted credits on the Eurodollar market, a main source of financing for Hungary through the 1970s.

Also, beginning last year the foreign banks have withdrawn unspecified millions of dollars deposited with the National Bank of Hungary.

These deposits are comparable to loans. In normal times the bank pays interest on this money, which the foreign banks "roll over" every three or six months. By leaving the money in the Bank of Hungary, the banks provide Hungary with additional liquidity and strengthen confidence in its finances. But as Western concern about East Bloc debts mounted last year, some bankers stopped rolling over the deposits and withdrew the funds as they matured.

As a result, the bank's reserves of gold and foreign currencies dipped from $2.4 billion as of Jan. 1, 1981, to $1.9 billion six months later. Since then, officials say, the reserves have hovered around that level. But the absence of new credits means that Hungary has to dip into the reserves or earn more convertible currency to pay off old loans.

In most respects, Hungary seems better positioned for the credit squeeze than most of its allies.

It turned a $1.2 billion trade deficit in 1978 into a small surplus in 1980 and 1981, and it has done this without harsh new measures such as import controls.

Hungary's agriculture, the most efficient and productive in Eastern Europe, is the country's main strength as it attempts to ride out the crisis. While Poland, Romania, East Germany and the Soviet Union spend billions of dollars a year importing American and Argentine grain, Hungary exports about $2 billion worth of food a year for dollars, marks, francs and pounds. Its wheat production more than doubled during the last decade.

Also, Hungary has cut back on Western oil imports from nearly 15 million barrels in 1979 to almost none last year. The streets of Budapest are being torn up to make way for mains that can use natural gas from Siberia in place of more expensive heating oil.

Unlike Romania and Poland, which are burdened by extremely heavy foreign debts coming due in 1982 and 1983, Hungary's bankers carefully have staggered the maturity of loans to push more of the country's debt repayment to the middle of the decade.

Meanwhile, Hungary has cultivated a reputation for sound banking practices.

It is the only country in the Soviet Bloc to have permitted the establishment of an "offshore" banking operation. In 1979, banks from Japan, Italy, West Germany, Austria and France established the Central European International Bank in Budapest. The Hungarian National Bank has a minority share in CEIB, which is exempt from Hungarian foreign exchange regulations and has made small investments in several Hungarian-Western joint ventures.

The skill of officials at the Hungarian National Bank at exploiting the intricacies of Western finance have become legendary in banking circles. For example, the bank reportedly has made profits by borrowing money in Western currencies that later declined in value, thus enabling Hungary to repay the money it borrowed in devalued currency.

Nevertheless, Western bankers say they still have reasons to be wary of Hungary's financial stability during the next few months.

Although the country showed a surplus in overall trade in Western currencies in 1981, it had a deficit in its trade with major industrial countries. This deficit was only offset by running up a large surplus in trade with other socialist countries whose economies are facing financial problems. This hard-currency trade, a relatively new development in Eastern Europe, so far has worked in Hungary's favor. But Western bankers fear that could change if countries such as Poland sharply reduce their imports.

Another problem is that the country's centralized financial system concentrates virtually the entire country's debt problems on the shoulders of a single institution--the Hungarian National Bank.

This system places enormous responsibilities on a single institution. It is as if the Federal Reserve Board in the United States were serving also as Bank of America, Citibank, Bankers Trust and all other lending institutions rolled into one.

Despite this awesome responsibility, bankers here insist they will be able to steer the country through the present difficulties. "You must remember that we do know the tricks of the trade," one of them said.